﻿using Microsoft.Practices.Unity;
using UnityDemo.Models;

namespace UnityDemo.RegAndResCode
{
    /// <summary>
    /// This sample shows the difference between a default registraion and named registration
    /// </summary>
    internal class RegisterNamedInterfacesAndClass : ISample
    {
        public RegisterNamedInterfacesAndClass()
        {
            var container = new UnityContainer(); // UnityInstanceProvider.NewUnityInstance;
            const string instanceName = "Queen duck Instance";

            // a default registration
            container.RegisterType<IDuck, KingDuck>();

            // a named registration
            container.RegisterType<IDuck, QueenDuck>(instanceName);

            var duck1 = container.Resolve<IDuck>();
            duck1.CheckDuckType();

            var duck2 = container.Resolve<IDuck>(instanceName);
            duck2.CheckDuckType();
        }
    }
}